<div class="sm-pop">
    <div id="dialog_form" class="layui-form" lay-filter="test1">
        <input type="hidden" name="id" value="<%=id%>">


        <div class="layui-form-item">
            <label class="layui-form-label"><i>*</i> 标题</label>
            <div class="layui-input-block">
                <input type="text" name="title" maxlength="20" value="<%=title%>" lay-verify="required" autocomplete="off"
                       placeholder="请输入标题" class="layui-input">
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label"><i>*</i>内容</label>
            <div class="layui-input-block">
                <textarea name="content" id="content" cols="30" rows="10"><%=content%></textarea>
            </div>
        </div>

        <fieldset class="layui-elem-field layui-field-title">
            <legend>图片 <span class="must">(必填)</span></legend>
        </fieldset>
        <div class="layui-form-item">
            <input type="hidden" name="imgPath">
            <div class="layui-upload-drag" id="uploader">
                <i class="layui-icon"></i>
                <p>点击上传，或将文件拖拽到此处</p>
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <textarea name="remark" maxlength="100" placeholder="请输入备注"
                          class="layui-textarea"><%=remark%></textarea>
            </div>
        </div>

    </div>
</div>




<script>
    layui.use(['layedit', "upload", "form"], function () {
        var layedit = layui.layedit;
        var $ = layui.$;
        var form = layui.form;
        var upload = layui.upload;
        form.render();

        // 设置富文本上传接口
        layedit.set({
            uploadImage: {
                url: '/managerImg/uploadFile',
                type: 'post'
            },
            uploadVideo: {
                url: '/managerImg/uploadFile',
                type: 'post'
            },
            uploadAudio: {
                url: '/managerImg/uploadFile',
                type: 'post'
            },
        });
        var layeditIndex = layedit.build('content');

//        var content = layedit.getContent(layeditIndex);
//        $("input[name='content']").val(content);



        //单图
        upload.render({
            elem: '#uploader',
            url: '/websitebanner/uploadFile',
            size: 5120,//KB,0或默认不限制
            done: function (result, index, upload) {
                if (result.success && result.data) {
                    $("#uploader").html("<img src='" + result.data.insideurl + "' style='width: 200px;height:200px;'/><p>点击重新上传，或将文件拖拽到此处</p>");
                    $("#dialog_form input[name=imgPath]").val(result.data.url);
                } else {
                    layer.msg('上传失败');
                }
            }
        });


    });
</script>